Package edu.claflin.finder.logic
Class Edge<D>
- java.lang.Object
-
- edu.claflin.finder.logic.Edge<D>
-
- Type Parameters:
D- the data type of the data attached to the edge object.
public class Edge<D> extends java.lang.ObjectRepresents an Edge in memory. A simple implementation requiring only two nodes and a single piece of edge data.- Version:
- 3.1 February 2, 2016
- Author:
- Charles Allen Schultz II
-
-
Field Summary
Fields Modifier and Type Field Description private DdataThe data attached to the edge.private NodedestinationThe node representing the destination.private NodesourceThe node representing the source.private booleanundirectedIndicates if this edge should be treated as being undirected.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Edgeduplicate(Node source, Node destination)Attempts to duplicate an Edge based on the supplied parameters.booleanequals(java.lang.Object o)DgetData()Access method for the Edge's data (such as weight).NodegetDestination()Access method for the Edge's destination.NodegetSource()Access method for the Edge's source.inthashCode()booleanisUndirected()Access method for the Edge's undirectedness parameter.voidsetData(D data)Access method for the Edge's data (such as weight).voidsetUndirected(boolean undirected)Access method for the Edge's undirectedness parameter.java.lang.StringtoString()
-
-
-
Field Detail
-
source
private final Node source
The node representing the source.
-
destination
private final Node destination
The node representing the destination.
-
data
private D data
The data attached to the edge.
-
undirected
private boolean undirected
Indicates if this edge should be treated as being undirected.
-
-
Constructor Detail
-
Edge
public Edge(Node source, Node destination, D data, boolean undirected)
Initializes the Edge object.- Parameters:
source- the Node representing the interaction source.destination- the Node representing the interaction destination.data- the Object representing the Edge data.undirected- the boolean indicating if this edge is undirected.
-
-
Method Detail
-
getSource
public Node getSource()
Access method for the Edge's source.- Returns:
- the Node representing the source.
-
getDestination
public Node getDestination()
Access method for the Edge's destination.- Returns:
- the Node representing the destination.
-
getData
public D getData()
Access method for the Edge's data (such as weight).- Returns:
- the Object representing the data.
-
setData
public void setData(D data)
Access method for the Edge's data (such as weight).- Parameters:
data- the new data for the edge.
-
isUndirected
public boolean isUndirected()
Access method for the Edge's undirectedness parameter.- Returns:
- the boolean indicating if this edge is undirected.
-
setUndirected
public void setUndirected(boolean undirected)
Access method for the Edge's undirectedness parameter.- Parameters:
undirected- a boolean indicating if this edge should be undirected.
-
duplicate
public Edge duplicate(Node source, Node destination)
Attempts to duplicate an Edge based on the supplied parameters. The data attached to the edge REMAINS THE SAME OBJECT as the original graph. As such, non-immutable objects will reflect changes across both edges. The supplied Node objects must be equivalent to the old ones.- Parameters:
source- the new Source node reference to utilize.destination- the new Destination node reference to utilize.- Returns:
- a duplicate Edge decoupled from the original Graph.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-